<template>
	流程信息
	<el-form :model="step" label-width="120px">

		<el-form-item label="标题">
			<el-input v-model="step.stepTitle" />
		</el-form-item>

		<el-form-item label="处理人">
			<el-select v-model="step.stepProcessorid" placeholder="please select your zone">
				<el-option v-for="(item,index) in users" :label="item.userName" :value="item.userId" @click="handleChange(index)" />
			</el-select>
		</el-form-item>

		<el-form-item label="处理意见">
			<el-input v-model="step.stepOpinions" :rows="5" type="textarea" placeholder="Please input" />
		</el-form-item>

		人事变更信息



		<el-form-item label="调动后部门">
			<el-select v-model="step.permanageDepartment" placeholder="please select your zone" @change="dpmchange">
				<el-option label="业务部" value="业务部" />
				<el-option label="人事部" value="人事部" />
				<el-option label="财务部" value="财务部" />
				<el-option label="项目部" value="项目部" />
			</el-select>
		</el-form-item>

		<el-form-item label="调动后职位">
			<el-select v-model="step.permanageTransfer" placeholder="please select your zone">
				<el-option v-for="item in posts" :label="item.postName" :value="item.postName" />
			</el-select>
		</el-form-item>

		<el-form-item label="调动后后工资">
			<el-input v-model="step.permanageSalary" />
		</el-form-item>



		<el-button type="primary" @click="onSubmit">提交</el-button>
		<el-button>取消</el-button>

	</el-form>
</template>

<script>
	import qs from 'qs'
	export default {
		data() {
			return {
				user: {

				},
				post: {
					postName: '',
					postDepartment: '',
				},
				posts: [],
				step: {
					stepTitle: '',
					creatorId: this.$store.state.user.userId,
					creatorName:this.$store.state.user.userName,
					stepProcessorid: null,
					stepProcessor:'',
					stepOpinions: '',
					permanageDepartment: '',
					permanageTransfer: '',
					permanageSalary: null,
					stepKind:'人事变更申请',
					stepIsend:'否',
				},
				users: [],

			}
		},
		methods: {
			onSubmit() {
				console.log(this.step)
				let that = this
				let str = qs.stringify(this.step)
				this.$axios.get("http://localhost:8080/step/insertpermanage?" + str).then(function(res) {
					console.log(res);
					if(res.data==1){
						alert("提交成功")
						that.$router.go(0);
					}
				})
			},
			dpmchange() {
				this.post.postDepartment = this.step.permanageDepartment
				let that = this
				let str = qs.stringify(this.post)
				console.log(this.post)
				this.$axios.get("http://localhost:8080/post/search?" + str).then(function(res) {
					console.log(res);
					that.posts = res.data;
					console.log(that.posts);
				})
			},
			getAllusers() {
				let that = this
				let str = qs.stringify(this.user)
				this.$axios.get("http://localhost:8080/user/search?" + str).then(function(res) {
					console.log(res);
					that.users = res.data;
					console.log(that.users);
				})
			},
			handleChange(index) {
				this.step.stepProcessor=this.users[index].userName
			}
		},
		created() {
			this.getAllusers()
		}

	}
</script>
<style>
</style>>
